/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TimerJFrame.java
 *
 * Created on 24.05.2012, 11:55:40
 */
package meditation;

import java.io.IOException;

import javax.media.NoPlayerException;

/**
 *
 * @author hassler
 */
public class TimerJFrame extends javax.swing.JFrame {

    /** Creates new form TimerJFrame */
    public TimerJFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        zeit_zum_HinsetzenTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        zeit_bis_zur_Mitte_TextField = new javax.swing.JTextField();
        zeit_bis_kurz_vor_EndeTextField = new javax.swing.JTextField();
        endeZeitTextField = new javax.swing.JTextField();
        zzHSchlaegeTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        zbzMSchlaegeTextField = new javax.swing.JTextField();
        zbkvESchlaegeTextField = new javax.swing.JTextField();
        eZSchlaegeTextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("start Timer");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Zeit bis zur Mitte");

        zeit_zum_HinsetzenTextField.setText("1");

        jLabel3.setText("Zeit zum Hinsetzen");
        jLabel3.setToolTipText("alle Zeiten in Minuten");

        jLabel4.setText("Zeit bis kurz vor Ende");

        jLabel5.setText("Endezeit");

        zeit_bis_zur_Mitte_TextField.setText("15");

        zeit_bis_kurz_vor_EndeTextField.setText("10");

        endeZeitTextField.setText("5");
        endeZeitTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endeZeitTextFieldActionPerformed(evt);
            }
        });

        zzHSchlaegeTextField.setText("3");

        jLabel1.setText("Anzahl der Schlaege");

        zbzMSchlaegeTextField.setText("2");

        zbkvESchlaegeTextField.setText("1");

        eZSchlaegeTextField.setText("3");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(zeit_bis_kurz_vor_EndeTextField)
                            .addComponent(zeit_bis_zur_Mitte_TextField)
                            .addComponent(endeZeitTextField)
                            .addComponent(zeit_zum_HinsetzenTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(eZSchlaegeTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(zbkvESchlaegeTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(zbzMSchlaegeTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(zzHSchlaegeTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zeit_zum_HinsetzenTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(zzHSchlaegeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zeit_bis_zur_Mitte_TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(zbzMSchlaegeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(zeit_bis_kurz_vor_EndeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(zbkvESchlaegeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(endeZeitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(eZSchlaegeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void endeZeitTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endeZeitTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_endeZeitTextFieldActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
			Media.sesshin(
			         tf2Int(zeit_zum_HinsetzenTextField),
			         tf2Int(zzHSchlaegeTextField),
			         tf2Int(zeit_bis_zur_Mitte_TextField),
			         tf2Int(zbzMSchlaegeTextField),                 
			         tf2Int(zeit_bis_kurz_vor_EndeTextField),
			         tf2Int(zbkvESchlaegeTextField),
			         tf2Int(endeZeitTextField),
			         tf2Int(eZSchlaegeTextField)
			         );
		} catch (NoPlayerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
       
       
                         
    }//GEN-LAST:event_jButton1ActionPerformed

    private int tf2Int(javax.swing.JTextField tf) {
        return Integer.parseInt(tf.getText().trim());
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TimerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TimerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TimerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TimerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TimerJFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField eZSchlaegeTextField;
    private javax.swing.JTextField endeZeitTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField zbkvESchlaegeTextField;
    private javax.swing.JTextField zbzMSchlaegeTextField;
    private javax.swing.JTextField zeit_bis_kurz_vor_EndeTextField;
    private javax.swing.JTextField zeit_bis_zur_Mitte_TextField;
    private javax.swing.JTextField zeit_zum_HinsetzenTextField;
    private javax.swing.JTextField zzHSchlaegeTextField;
    // End of variables declaration//GEN-END:variables
}
